/**
 * Created by chenyong on 2015/12/16.
 */

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        bigpixel:{
            dist:'dist'
        },
      jshint:{
        all:['public/scripts/bigpixel.panoviewer.js'],
        options:{
          browser:true,
          devel:true
        }
      },
        clean:{
            dist:{
                src: ['<%= bigpixel.dist %>/*']
            }
        },
        copy:{
            dist:{
                files:[
                    {
                        expand: true,
                        dot: true,
                        cwd: '',
                        dest: '<%= bigpixel.dist %>',
                        src: [
                            'app.js',
                            'routes.js',
                            'sockets.js',
                            'package.json',
                            'auth/**',
                            'bin/**',
                            'common/**',
                            'config/**',
                            'public/**',
                            'routes/**',
                            'service/**',
                            'views/**'
                        ]
                    }
                ]
            }
        },
        uglify:{
          dist:{
              files: [{
                  expand: true,
                  cwd: '<%= bigpixel.dist %>/public/scripts',
                  src: ['**/*.js', '!**/*.min.js'],
                  dest: '<%= bigpixel.dist %>/public/scripts'
              }]
          }
        },
        cssmin:{
            dist:{
                files: [{
                    expand: true,
                    cwd: '<%= bigpixel.dist %>/public/stylesheets',
                    src: ['*.css', '!*.min.css'],
                    dest: '<%= bigpixel.dist %>/public/stylesheets'
                }]
            }
        },
        htmlmin:{
            dist: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true,
                    minifyJS:true
                },
                files: [
                    {expand: true, cwd: '<%= bigpixel.dist %>/views', src: ['**/*.html'], dest: '<%= bigpixel.dist %>/views'}
                ]
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
  grunt.loadNpmTasks('grunt-contrib-jshint');


    grunt.registerTask('default', ['clean', 'copy','uglify','cssmin','htmlmin']);

};
